package com.heima.mapper;

import com.heima.pojo.entity.Sku;
import com.heima.pojo.entity.SkuClass;
import com.heima.pojo.vo.SkuClassVo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SkuMapper {
    //添加商品分类
    @Options(useGeneratedKeys = true,keyProperty = "classId")
    @Insert("insert into tb_sku_class (class_name,parent_id)" +
            "value (#{className},#{parentId}) ")
    Boolean addSkuClass(SkuClass skuClass);

    //查询商品分类集合（动态查询）
    List<SkuClass> getSkuClass(SkuClass skuClass);

    //修改商品分类名称
    @Update("update tb_sku_class set class_name = #{className} where class_id = #{classId}")
    Boolean updateSkuClsName(Integer classId, String className);

    //删除商品分类
    @Delete("delete from tb_sku_class where class_id = #{classId} ")
    void deleteSkuCls(Integer classId);

    //查询商品分类根据id
    @Select("select sc.class_id,sc.class_name from tb_sku_class sc where class_id = #{classId}")
    SkuClass getSkuClassById(Integer classId);

    //新增商品（动态）
    Boolean save(Sku sku);

    //分页查询商品列表
    List<Sku> getSku(String skuName);

    //修改商品信息
    Boolean updateSku(String skuId, Sku sku);

//    //根据id删除商品
//    @Delete("delete * from tb_sku where sku_id =#{skuId}")
//    void deleteBySkuId(Long skuId);

    //根据id查询商品详情
    @Select("select * from tb_sku where sku_id =#{skuId}")
    Sku getSkuById(String skuId);

}
